<template>
  <div class="app-container">
    <!-- 查询和其他操作 -->
    <div class="filter-container">
      <el-input v-model="listQuery.stationName" clearable class="filter-item" style="width: 200px;" placeholder="请输入电台名称"/>
      <el-input v-model="listQuery.freqName" clearable class="filter-item" style="width: 200px;" placeholder="请输入频率名称"/>
      <el-input v-model="listQuery.progName" clearable class="filter-item" style="width: 200px;" placeholder="请输入节目名称"/>
      <el-input v-model="listQuery.classify" clearable class="filter-item" style="width: 200px;" placeholder="请输入分类名称"/>
      <el-button class="filter-item" icon="el-icon-search" @click="handleFilter">查找</el-button>
      <!--      <el-button class="filter-item" icon="el-icon-download">下载所有</el-button>-->
    </div>
    <!-- 查询结果 -->
    <el-table v-loading="listLoading" :data="list" element-loading-text="正在查询中。。。" border fit highlight-current-row>
      <el-table-column type="expand">
        <template slot-scope="props">
          <radio-program-card :programme-id="props.row.progCode"/>
        </template>
      </el-table-column>
      <el-table-column align="center" label="序号" prop="id" width="80"/>
      <el-table-column align="center" label="电台" prop="stationName"/>
      <el-table-column align="center" label="频率" prop="freqName"/>
      <el-table-column align="center" label="节目" prop="progName"/>
      <el-table-column align="center" label="节目编码" prop="progCode" width="100"/>
      <el-table-column align="center" label="分类" prop="cateName" width="100"/>
      <el-table-column align="center" label="分级" prop="classify" width="80"/>
      <el-table-column align="center" label="创建" prop="addTime"/>

      <!--      <el-table-column align="center" label="操作" width="100" class-name="small-padding">-->
      <!--        <template slot-scope="scope">-->
      <!--          <el-button type="primary" size="mini" @click="handleCreateClip(scope.row)">创建剪辑</el-button>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
    </el-table>

    <pagination  :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
  </div>
</template>
<script>

import BackToTop from '../../../components/BackToTop'
import Pagination from '../../../components/Pagination'
import ObjectUtil from '../../../utils/object-util'
import { apiProgram } from '../../../api/meterial/program'
import { apiCbct } from '../../../api/cbct/cbct'
import RadioProgramPlayList from './play_list'
import RadioProgramCard from './programCard'

export default {
  name: 'RadioProgramList',
  components: { RadioProgramCard, RadioProgramPlayList, BackToTop, Pagination },
  mixins: [
  ],
  data() {
    return {
      list: [],
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 20,
        id: undefined,
        stationName: undefined,
        freqName: undefined,
        progName: undefined,
        classify: undefined,
        sort: 'add_time',
        order: 'desc'
      }
    }
  },
  created() {
    this.Init()
  },
  methods: {
    getNewStatus(status) {
      return (status + 1) % 2
    },
    Init() {
      this.getList()
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    getList() {
      this.listLoading = true
      apiProgram.list({ ...this.listQuery }).then(res => {
        const resList = res.data.data.list || []
        this.list = resList.filter(t => ObjectUtil.notNull(t))
      }).finally(() => {
        this.listLoading = false
      })
    },
    handleCreateClip(row) {
      apiCbct.getProgrammeInfo({ programmeId: row.progCode }).then(res => {
        console.log(res)
      })
    }
  }
}
</script>

<style scoped>

</style>
